package org.hnxxxy.ebms.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiOperation;
import org.hnxxxy.ebms.common.Result;
import org.hnxxxy.ebms.pojo.Daliy;
import org.hnxxxy.ebms.pojo.RecruitStu;
import org.hnxxxy.ebms.service.DaliyService;
import org.hnxxxy.ebms.service.RecruitStuService;
import org.hnxxxy.ebms.vo.DaliyVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author WANGWEI
 * @since 2021-06-10
 */
@RestController
@RequestMapping("//daliy")
public class DaliyController {
    @Autowired
    public DaliyService daliyService;

    @PostMapping("/add")
    @ApiOperation(value = "增加招生日报")
    public Result<String> addDaliy(@RequestBody Daliy daliy){
        return daliyService.add(daliy);
    }

    @DeleteMapping("/del/{id}")
    @ApiOperation(value = "删除招生日报")
    public Result<String> delDaliy(@PathVariable("id") Integer id){
        if (daliyService.removeById(id)){
            return Result.success(200,"删除成功");
        }
        return Result.fail("删除失败");
    }

    @PostMapping("/update")
    @ApiOperation(value = "修改招生日报")
    public Result<String> updateDaliy(@RequestBody Daliy daliy){
        if (daliyService.updateById(daliy)){
            return Result.success(200,"修改成功");
        }
        return Result.fail("修改失败");
    }

    @GetMapping("/get/{page}")
    @ApiOperation(value = "查询招生日报")
    public Result<IPage<DaliyVo>> getDaliy(@PathVariable("page") int page){
        return daliyService.getDaliy(page);
    }

    @GetMapping("/getName/{name}/{page}")
    @ApiOperation(value = "根据学生姓名搜索")
    public Result<IPage<DaliyVo>> getDaliyByName(@PathVariable("name") String name,@PathVariable("page") int page){
        return daliyService.getDaliyByName(name,page);
    }

}
